<?php
/**
 * @author HX<titanrain@163.com>
 */
class UploadAR extends CActiveRecord {
	public static function model($className=__CLASS__){
		return parent::model($className);
	}

	public function tableName(){
		return self::tblName();
	}
	
	public static function tblName(){
		return 'ccs8_upload';
	}
	
	public static function persist($bookId){
		$userId = User::id();
		if($userId === 0){
			return;
		}
		$cnt = DBUtil::count(self::tblName(),"fk_user=$userId and fk_book=$bookId");
		if($cnt > 0){
			return;
		}
		$props = array('fk_user'=>$userId,'fk_book'=>$bookId,'ctime'=>time());
		DBUtil::insert(self::tblName(),$props);
	}

}